#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/2/12 3:12
# @Author  : leon yan
# @Site    : 
# @File    : qlogical_obj.py
# @Software: PyCharm

import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot

import Globalist as gl
from lib.qpulsesignal import Qpulsesignal


class Qlogical_obj(QObject):
    pulseSignal = pyqtSignal()
    simMove = pyqtSignal(int)

    def __init__(self):
        super().__init__()
        # gl.init()
        self.QpulseObj = Qpulsesignal()
        self.QpulseObj.start()
        self.QpulseObj.bPulse.connect(self.statusUpdate)

    def getTask(self, num):
        """num:到对应的工位仓(堆栈)取任务"""
        return gl.getQueue2View(num)

    '''每秒进行状态更新'''

    @pyqtSlot()
    def statusUpdate(self):
        bsimulationSwitch = 1
        if bsimulationSwitch:
            # if gl.getQueue2View(0):
            #     self.simMove.emit(0)
            # '''读取工位板子信号'''
            # hasLst = self._SimulationReadHasBoard()
            # '''模拟辊筒运行信号'''
            # self._simulationStationRun(hasLst)
            pass
        self.pulseSignal.emit()

    '''子函数'''

    def _simulationStationRun(self, hasBoardList):
        """Plc模拟：各工位的运行控制输出"""
        pass

    def _simulationMaching(self):
        pass


if __name__ == '__main__':
    app = QApplication(sys.argv)
    aa = Qlogical_obj()

    sys.exit(app.exec())
